import http from './libs/request'

// post类型对象参数转为get类型url参数
import queryParams from './libs/function/queryParams.js'
// 路由封装
import route from './libs/function/route.js'

// 对象和数组的深度克隆
import deepClone from './libs/function/deepClone.js'
// 对象深度拷贝
import deepMerge from './libs/function/deepMerge.js'

// 规则检验
import test from './libs/function/test.js'
// toast提示，对uni.showToast的封装
import toast from './libs/function/toast.js'
// 获取sys()和os()工具方法
// 获取设备信息，挂载到$u的sys()(system的缩写)属性中，
// 同时把安卓和ios平台的名称"ios"和"android"挂到$u.os()中，方便取用
import {
	sys,
	os
} from './libs/function/sys.js'
// 防抖方法
import debounce from './libs/function/debounce.js'
// 节流方法
import throttle from './libs/function/throttle.js'


const $u = {
	queryParams: queryParams,
	route: route,
	sys,
	os,
	get: http.get,
	post: http.post,
	put: http.put,
	'delete': http.delete,
	test,
	deepClone,
	deepMerge,
	http,
	toast,
	debounce,
	throttle,
}

// $u挂载到uni对象上
uni.$u = $u

const install = Vue => {
	Vue.prototype.$u = $u
}

export default {
	install
}